<?php

/**
 * header()方法工具类
 * @author hetf
 *
 */
class HeaderUtils {
	
	/**
	 * 根据相应的时间页面跳转
	 *
	 * @param unknown_type $time        	
	 * @param unknown_type $url        	
	 */
	public static function refresh($time, $url) {
		header ( 'refresh:' . $time . ';url=' . urldecode ( $url ) );
	}
	
	/**
	 * 不缓存数据
	 * @return boolean
	 */
	public static function noCache() {
		if (headers_sent ()) {
			return FALSE;
		}
		header ( 'pragma: public' ); // HTTP/1.0
		header ( 'expires: Mon, 26 Jul 1997 05:00:00 GMT' );
		@header ( 'last-modified: ' . gmdate ( 'D, d M Y H:i:s' ) . ' gmt' ); // !
		@header ( 'cache-control: no-store, no-cache, must-revalidate' ); // HTTP/1.1
		header ( 'cache-control: private, post-check=0, pre-check=0, max-age=0', FALSE ); // HTTP/1.1
		header ( 'pragma: no-cache' ); // HTTP/1.0
		header ( 'expires: 0' );
	}
	
	/**
	 * 状态200
	 */
	public static function status200() {
		header ( 'HTTP/1.1 200 OK' );
	}
	
	/**
	 * 状态301
	 */
	public static function status301() {
		header ( 'HTTP/1.1 301 Moved Permanently' );
	}
	
	/**
	 * 状态 404
	 */
	public static function status404() {
		header ( 'HTTP/1.1 404 Not Found' );
	}
	
	/**
	 * 跳轉
	 *
	 * @param string $url        	
	 */
	public static function location($url) {
		header ( 'Location:' . urldecode ( $url ) );
	}
	
	/**
	 * 设置字符集
	 *
	 * @param string $charset        	
	 */
	public static function charset($charset) {
		header ( 'Content-Type: text/html; charset=' . $charset );
	}
}

?>